package com.timoon.testng.demo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Random;

import org.testng.annotations.Test;

import com.timoon.sample.dao.model.TUser;

/**
 *<p></p>
 *<p></p>
 *<p>Copyright:Copyright(c)2013.4.1</p>
 *<p>Company:timoon</p>
 *@author 付乐天
 *@version 1.0 */
public class ListTest {

	@Test
	public void sort(){
		List<TUser> users=new ArrayList<>();
		
		Random random=new Random(1000);
		
		for(int i=0;i<10;i++){
			TUser user=new TUser();
			user.setId(Math.abs(random.nextInt()));
			users.add(user);
		}
		
		Collections.sort(users, new Comparator<TUser>() {

			@Override
			public int compare(TUser o1, TUser o2) {
				// TODO Auto-generated method stub
				return o2.getId()-o1.getId();
			}
		});
		
		for(TUser user:users){
			System.err.println(user.getId());
		}
	}
}
